<? 
    session_start();
	include ("../core/conn.php");
	global $db;	
	$db = get_conn();
	
	$pais= $_GET['p'];
	$tabla= $_GET['t'];	

	$sql ="select id_tc from cobro_pais where id_pais = ".$pais." and id_tc <> ".$tabla;
	//echo $sql; 
	$result = mysql_query($sql);	
	if($result){
		$cantidad = mysql_num_rows($result);
		if($cantidad ==0){
			echo "<input type='hidden' name='already_listed' value='F' id='already_listed'  />	
				  <input type='hidden' name='already_name' value='xxx' id='already_name' />";			
		}else{
			$row = mysql_fetch_array($result);
			$id_tc = $row['id_tc'];
			$tabla_name = get_nombre_tabla($id_tc);
	
			if($id_tc == ""){
				echo "<input type='hidden' name='already_listed' value='F' id='already_listed'  />";
			}else{
				echo "<input type='hidden' name='already_listed' value='T' id='already_listed' />
					  <input type='hidden' name='already_name' value='".$tabla_name."' id='already_name' />";
			}
		}
	}else{
		error_handling(__FUNCTION__.$sql,mysql_error());
	}
	
	function get_nombre_tabla($id_tc){
		if($id_tc!=''){
			$sql ="select nombre from cobro_envio where id_tc = ".$id_tc;
			$result = mysql_query($sql);	
			if($result){
				$row = mysql_fetch_array($result);
				$nombre = $row['nombre'];
				return $nombre;
			}else{
				error_handling(__FUNCTION__.$sql,mysql_error());
			}			
		}
	}
?>